package com.tankgame4;

import java.util.Vector;

public class Hero extends Tank {
    // 定义一个Shot对象，表示一个射击子弹线程
    Shot shot = null;
    Vector<Shot> shots = new Vector<>();
    public Hero(int x, int y) {
        super(x, y);
    }

    public void shotEnemyTank() {
        // 创建Shot对象，根据当前Hero对象的方向和位置来创建Shot对象
        switch (getDirect()) {
            case 0:
                shot = new Shot(getX() + 20, getY(), 0);
                break;
            case 1:
                shot = new Shot(getX() + 60, getY() + 20, 1);
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, 2);
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, 3);
                break;
        }

        shots.add(shot);
        // 启动子弹线程
        new Thread(shot).start();
    }


}
